import 'dart:io';

import 'package:flutter_luban/flutter_luban.dart';

class CompressPhoto {

  static compressPhoto(File file, callback) {
    callback(file);
    // 停止压缩功能
    return ;
    print('原路径:'+file.toString());
    List<String> sl = file.toString().split('/');
    sl..remove('File: \'')..removeLast();
    String dir = '/';
    int i = 1;
    sl.forEach((str) {
      if (i < sl.length) {
        dir += str+'/';
      } else {
        dir += str;
      }
      i++;
    });
    print(dir);

    CompressObject compressObject = CompressObject(
      imageFile: file,
      path: dir
    );
    Luban.compressImage(compressObject).then((_path) {
      return callback(File(_path));
    });
  }

}
